
from django.conf.urls import url
# from meiduo_admin.views.login_views import LoginAPIView
from rest_framework_jwt.views import obtain_jwt_token
from meiduo_admin.views.home_views import *
from meiduo_admin.views.user_views import *
from meiduo_admin.views.sku_views import *
from meiduo_admin.views.spu_views import *
from meiduo_admin.views.spec_views import *
from meiduo_admin.views.option_views import *
from meiduo_admin.views.image_views import *
from meiduo_admin.views.order_views import *
from meiduo_admin.views.perm_views import *
from meiduo_admin.views.group_views import *
from meiduo_admin.views.admin_views import *
from rest_framework.routers import SimpleRouter

urlpatterns = [
    # url(r'^authorizations/$', LoginAPIView.as_view()),

    # obtain_jwt_token: rest_framework_jwt拓展为我们提供的一个视图函数，用来签发token的！！
    url(r'^authorizations/$', obtain_jwt_token),

    # 商品日访问量
    url(r'^statistical/goods_day_views/$', GoodsDayVisitView.as_view()),
    # 序列化返回多条用户数据
    url(r'^users/$', UserAPIView.as_view()),

    # sku表管理
    url(r'^skus/$', SKUViewSet.as_view({"get": "list", "post": "create"})),
    url(r'^skus/(?P<pk>\d+)/$', SKUViewSet.as_view({"get":"retrieve",
                                                    "put":"update",
                                                    "delete":"destroy"})),

    # 获取新建sku可选的三级分类
    url(r'^skus/categories/$', GoodsCategoryView.as_view()),
    # 获取新建sku可选spu信息
    url(r'^goods/simple/$', SPUSimpleView.as_view()),
    # 获取可选的spu的规格信息
    url(r'^goods/(?P<pk>\d+)/specs/$', SpecOptView.as_view()),


    # spu管理
    url(r'^goods/$', SPUViewSet.as_view({"get": "list", "post":"create"})),
    url(r'^goods/(?P<pk>\d+)/$', SPUViewSet.as_view({"get":"retrieve",
                                                     "put":"update",
                                                     "delete":"destroy"})),

    # 后去新建spu可选品牌
    url(r'^goods/brands/simple/$', BrandView.as_view()),
    # 获取可选的一级分类
    url(r'^goods/channel/categories/$', SPUCategoryView.as_view()),
    # 获取可选的二或三级分类
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', SPUCategoryView.as_view()),


    # spec规格表管理
    # goods/specs/ + GET  =  list  序列化返回多条数据
    # goods/specs/ + POST =  create 反序列化新建单一数据
    url(r'goods/specs/$', SpecViewSet.as_view({"get":"list", "post": "create"})),
    # goods/specs/(?P<pk>\d+)/ + GET = retrieve 序列化返回单一数据
    # goods/specs/(?P<pk>\d+)/ + PUT = update 反序列化更新单一对象
    # goods/specs/(?P<pk>\d+)/ + DELETE = destroy 反序列化删除单一对象
    url(r'goods/specs/(?P<pk>\d+)/$', SpecViewSet.as_view({"get":"retrieve",
                                                           "put":"update",
                                                           "delete": "destroy"})),


    # 选项表管理
    url(r'^specs/options/$', OptionViewSet.as_view({'get':'list', 'post':'create'})),
    url(r'^specs/options/(?P<pk>\d+)/$', OptionViewSet.as_view({'get':'retrieve',
                                                                'put':'update',
                                                                'delete':'destroy'})),


    # 获取新建单一选项信息可选规格
    url(r'^goods/specs/simple/$', OptSpecView.as_view()),


    # 图片管理
    url(r'^skus/images/$', ImageViewSet.as_view({"get":"list", "post":"create"})),
    url(r'^skus/images/(?P<pk>\d+)/$', ImageViewSet.as_view({"get":"retrieve",
                                                             "put":"update",
                                                             "delete":"destroy"})),

    # 新增图片可选sku信息获取
    url(r'^skus/simple/$', SKUSimpleView.as_view()),

    # 订单管理
    url(r'^orders/$', OrderViewSet.as_view({'get':'list'})),
    url(r'^orders/(?P<pk>\d+)/$', OrderViewSet.as_view({'get':'retrieve'})),
    # 修改订单状态
    url(r'^orders/(?P<pk>\d+)/status/$', OrderViewSet.as_view({'patch':'partial_update'})),


    # 权限表管理
    url(r'^permission/perms/$', PermViewSet.as_view({"get":"list", "post":"create"})),
    url(r'^permission/perms/(?P<pk>\d+)/$', PermViewSet.as_view({"get":"retrieve",
                                                                 "put":"update",
                                                                 "delete":"destroy"})),

    # 新建权限可选类型
    url(r'^permission/content_types/$', ContentTypeView.as_view()),


    # 分组表管理
    url(r'^permission/groups/$', GroupViewSet.as_view({"get":"list", 'post':"create"})),
    url(r'^permission/groups/(?P<pk>\d+)/$', GroupViewSet.as_view({"get":"retrieve",
                                                                   "put":"update",
                                                                   "delete":"destroy"})),

    # 新建分组可选的权限
    url(r'^permission/simple/$', PermSimpleView.as_view()),


    # 管理员管理
    url(r'^permission/admins/$', AdminViewSet.as_view({'get':'list', "post":"create"})),
    url(r'^permission/admins/(?P<pk>\d+)/$', AdminViewSet.as_view({'get':'retrieve',
                                                                   'put':'update',
                                                                   'delete':'destroy'})),
    # 新增用户，可选分组数据获取
    url(r'^permission/groups/simple/$', GroupSimpleView.as_view()),
]


router = SimpleRouter()
router.register(prefix="statistical", viewset=HomeViewSet, base_name="Home")
urlpatterns += router.urls









